package com.jifeng.br.pjj.bookreader.controller.api;

import com.jifeng.br.pjj.bookreader.entity.VipEntity;
import com.jifeng.br.pjj.bookreader.service.VipService;
import com.jifeng.br.pjj.bookreader.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author PangJunjie
 * @Date 2023/7/20/020
 */
@RequestMapping("/api/vip")
@RestController
public class VipApiController {
    @Autowired
    private VipService vipService;

    @PostMapping("/update")
    public R update(@RequestBody VipEntity vip) {
        vipService.updateVip(vip);
        return R.ok();
    }

    @GetMapping("/info/{vipId}")
    public R info(@PathVariable int vipId) {
        return R.data(vipService.getById(vipId));
    }

    @GetMapping("/author")
    public R author(VipEntity vip) {
        vipService.updateAuthor(vip);
        return R.ok();
    }

}
